<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="gheat.css" type='text/css' />
<link rel="SHORTCUT ICON" href="icons/zeta.ico" />
<link rel='start' href='http://www.zetadev.com/software/gheat/' title='Gheat Homepage' />
<link rel="first" href="gheat.html" title='Gheat' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="about.html" />
<link rel="prev" href="configuration.html" />
<link rel="parent" href="gheat.html" />
<link rel="next" href="about.html" />
<meta name='aesop' content='information' />
<title>4. The db.py script</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3. Configuration"
  href="configuration.html"><img src='icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="Gheat"
  href="gheat.html"><img src='icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="About this document ..."
  href="about.html"><img src='icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Gheat</td>
<td class='online-navigation'><img src='icons/blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><img src='icons/blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><img src='icons/blank.png'
  border='0' height='32'  alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="configuration.html">3. Configuration</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="gheat.html">Gheat</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="about.html">About this document ...</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION004000000000000000000"></A>
<A NAME="db.py"></A>
<BR>
4. The db.py script
</H1>

<P>
The script at <span class="file">__/bin/db.py</span> is used to manage the database at 
<span class="file">__/var/points.db</span>. It's available subcommands are:

<P>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Subcommand</th>
      <th class="left"  >Description</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline"><code>clear</code></td>
        <td class="left"  >Remove all points from the database</td></tr>
    <tr><td class="left"   valign="baseline"><code>count</code></td>
        <td class="left"  >Print the number of points in the database to <span class="file">stdout</span></td></tr>
    <tr><td class="left"   valign="baseline"><code>delete</code></td>
        <td class="left"  >Delete the database from the filesystem</td></tr>
    <tr><td class="left"   valign="baseline"><code>sync</code></td>
        <td class="left"  >Update the database from the file at <span class="file">__/var/points.txt</span></td></tr></tbody>
</table></div>

<P>
For the <var>clear</var>, <var>count</var>, and <var>sync</var> subcommands, the database will
be created if it does not exist. The default subcommand is <var>sync</var>. 

<P>
The <span class="file">__/var/points.txt</span> file is a CSV-formatted file with three fields:
<var>point id</var>, <var>latitude</var>, and <var>longitude</var>. The <var>point id</var> field
can be any string. If it is not unique within the <span class="file">points.txt</span> file then
the last point with a given <var>point id</var> will override any previous points
with that same <var>point id</var>. Gheat uses the <var>point id</var> field to keep
track of when points should be removed from the database, as well as when
points are updated, in order to tell when the tile cache ought to be flushed.
The <var>latitude</var> and <var>longitude</var> fields must be floats. Multiple data
points may have the same latitude and longitude in order to increase the
intensity of that geographic point on the heatmap.

<P>
The <var>sync</var> subcommand outputs a token for each point in the
<span class="file">points.txt</span> file:

<P>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Token</th>
      <th class="left"  >Meaning</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline"><code>.</code></td>
        <td class="left"  >The point was not modified since the last time it was seen</td></tr>
    <tr><td class="left"   valign="baseline"><code>o</code></td>
        <td class="left"  >The point was modified and has been updated</td></tr>
    <tr><td class="left"   valign="baseline"><code>O</code></td>
        <td class="left"  >This is a new point</td></tr></tbody>
</table></div>

<P>
The number of points deleted can be determined by using the <var>count</var>
subcommand before and after the <var>sync</var> subcommand.

<P>

<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="3. Configuration"
  href="configuration.html"><img src='icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="Gheat"
  href="gheat.html"><img src='icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="About this document ..."
  href="about.html"><img src='icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Gheat</td>
<td class='online-navigation'><img src='icons/blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><img src='icons/blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><img src='icons/blank.png'
  border='0' height='32'  alt='' width='32' /></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="configuration.html">3. Configuration</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="gheat.html">Gheat</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="about.html">About this document ...</A>
</div>
</div>
<hr />
<span class="release-info">Release 0.2, documentation updated on April 29, 2008.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<a href="http://www.zetadev.com/software/gheat/">Gheat</a> is copyright &copy; 2007-2008 by Chad Whitacre and contributors, and is offered under the MIT license.
</ADDRESS>
</BODY>
</HTML>
